package com.chak.voyage.data.mapper;

import com.chak.voyage.data.entity.TNote;
import com.chak.voyage.data.entity.TNoteExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TNoteMapper {
    @SelectProvider(type=TNoteSqlProvider.class, method="countByExample")
    int countByExample(TNoteExample example);

    @DeleteProvider(type=TNoteSqlProvider.class, method="deleteByExample")
    int deleteByExample(TNoteExample example);

    @Delete({
        "delete from t_note",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into t_note (type, content_id, ",
        "url, title, writer_url, ",
        "start_date, end_date, ",
        "money, viewer_count, ",
        "like_count, positions, ",
        "write_time, create_time, ",
        "content)",
        "values (#{type,jdbcType=INTEGER}, #{contentId,jdbcType=INTEGER}, ",
        "#{url,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{writerUrl,jdbcType=VARCHAR}, ",
        "#{startDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, ",
        "#{money,jdbcType=INTEGER}, #{viewerCount,jdbcType=INTEGER}, ",
        "#{likeCount,jdbcType=INTEGER}, #{positions,jdbcType=VARCHAR}, ",
        "#{writeTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{content,jdbcType=LONGVARCHAR})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(TNote record);

    @InsertProvider(type=TNoteSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(TNote record);

    @SelectProvider(type=TNoteSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="content_id", property="contentId", jdbcType=JdbcType.INTEGER),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="writer_url", property="writerUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="money", property="money", jdbcType=JdbcType.INTEGER),
        @Result(column="viewer_count", property="viewerCount", jdbcType=JdbcType.INTEGER),
        @Result(column="like_count", property="likeCount", jdbcType=JdbcType.INTEGER),
        @Result(column="positions", property="positions", jdbcType=JdbcType.VARCHAR),
        @Result(column="write_time", property="writeTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<TNote> selectByExampleWithBLOBs(TNoteExample example);

    @SelectProvider(type=TNoteSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="content_id", property="contentId", jdbcType=JdbcType.INTEGER),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="writer_url", property="writerUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="money", property="money", jdbcType=JdbcType.INTEGER),
        @Result(column="viewer_count", property="viewerCount", jdbcType=JdbcType.INTEGER),
        @Result(column="like_count", property="likeCount", jdbcType=JdbcType.INTEGER),
        @Result(column="positions", property="positions", jdbcType=JdbcType.VARCHAR),
        @Result(column="write_time", property="writeTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TNote> selectByExample(TNoteExample example);

    @Select({
        "select",
        "id, type, content_id, url, title, writer_url, start_date, end_date, money, viewer_count, ",
        "like_count, positions, write_time, create_time, content",
        "from t_note",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="content_id", property="contentId", jdbcType=JdbcType.INTEGER),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="writer_url", property="writerUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="start_date", property="startDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_date", property="endDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="money", property="money", jdbcType=JdbcType.INTEGER),
        @Result(column="viewer_count", property="viewerCount", jdbcType=JdbcType.INTEGER),
        @Result(column="like_count", property="likeCount", jdbcType=JdbcType.INTEGER),
        @Result(column="positions", property="positions", jdbcType=JdbcType.VARCHAR),
        @Result(column="write_time", property="writeTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    TNote selectByPrimaryKey(Integer id);

    @UpdateProvider(type=TNoteSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TNote record, @Param("example") TNoteExample example);

    @UpdateProvider(type=TNoteSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") TNote record, @Param("example") TNoteExample example);

    @UpdateProvider(type=TNoteSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") TNote record, @Param("example") TNoteExample example);

    @UpdateProvider(type=TNoteSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TNote record);

    @Update({
        "update t_note",
        "set type = #{type,jdbcType=INTEGER},",
          "content_id = #{contentId,jdbcType=INTEGER},",
          "url = #{url,jdbcType=VARCHAR},",
          "title = #{title,jdbcType=VARCHAR},",
          "writer_url = #{writerUrl,jdbcType=VARCHAR},",
          "start_date = #{startDate,jdbcType=TIMESTAMP},",
          "end_date = #{endDate,jdbcType=TIMESTAMP},",
          "money = #{money,jdbcType=INTEGER},",
          "viewer_count = #{viewerCount,jdbcType=INTEGER},",
          "like_count = #{likeCount,jdbcType=INTEGER},",
          "positions = #{positions,jdbcType=VARCHAR},",
          "write_time = #{writeTime,jdbcType=TIMESTAMP},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(TNote record);

    @Update({
        "update t_note",
        "set type = #{type,jdbcType=INTEGER},",
          "content_id = #{contentId,jdbcType=INTEGER},",
          "url = #{url,jdbcType=VARCHAR},",
          "title = #{title,jdbcType=VARCHAR},",
          "writer_url = #{writerUrl,jdbcType=VARCHAR},",
          "start_date = #{startDate,jdbcType=TIMESTAMP},",
          "end_date = #{endDate,jdbcType=TIMESTAMP},",
          "money = #{money,jdbcType=INTEGER},",
          "viewer_count = #{viewerCount,jdbcType=INTEGER},",
          "like_count = #{likeCount,jdbcType=INTEGER},",
          "positions = #{positions,jdbcType=VARCHAR},",
          "write_time = #{writeTime,jdbcType=TIMESTAMP},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(TNote record);
}